<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript">
	function writeBoard(boardNo){
		var form = document.writeForm;
		
		if(form.title.value==""){
			alert("제목을 입력해주세요");
			form.title.focus();
			return false;
		}
		
		if(boardNo==21){
			var IMG_FORMAT = "\.(bmp|gif|jpg|jpeg|png)$";
	  		if((new RegExp(IMG_FORMAT, "i")).test(document.writeForm.uploadFile.value)){ 
	  			form.submit();
	    	}else{
	    		alert("파일첨부가 되지 않았거나 이미지 파일만 업로드 하실 수 있습니다.");
				return false;
	    	}
		}
		if(boardNo!=21){
			if(form.content.value==""){
				alert("내용을 입력해주세요");
				form.content.focus();
				return false;
			}
		}
		form.submit();
	}
</script>
<style type="text/css">
.writeBoardBtn {
	font-size:12px;
	font-family:Verdana;
	font-weight:bold;
	-moz-border-radius:2px;
	-webkit-border-radius:2px;
	border-radius:2px;
	border:1px solid #dcdcdc;
	padding:5px 10px;
	text-decoration:none;
	background:-webkit-gradient( linear, left top, left bottom, color-stop(5%, #d9d5d9), color-stop(100%, #bababa) );
	background:-moz-linear-gradient( center top, #d9d5d9 5%, #bababa 100% );
	background:-ms-linear-gradient( top, #d9d5d9 5%, #bababa 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d9d5d9', endColorstr='#bababa');
	background-color:#d9d5d9;
	color:#4f4f4f;
	display:inline-block;
	text-shadow:0px 0px 0px #ffffff;
 	-webkit-box-shadow:inset 0px 0px 0px 0px #ffffff;
 	-moz-box-shadow:inset 0px 0px 0px 0px #ffffff;
 	box-shadow:inset 0px 0px 0px 0px #ffffff;
}.writeBoardBtn:hover {
	background:-webkit-gradient( linear, left top, left bottom, color-stop(5%, #bababa), color-stop(100%, #d9d5d9) );
	background:-moz-linear-gradient( center top, #bababa 5%, #d9d5d9 100% );
	background:-ms-linear-gradient( top, #bababa 5%, #d9d5d9 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#bababa', endColorstr='#d9d5d9');
	background-color:#bababa;
}.writeBoardBtn:active {
	position:relative;
	top:1px;
}
</style>

</head>
<body>
<h3 align="center">글쓰기</h3>
<form method="post" action="write_board.do" enctype="multipart/form-data" name="writeForm">
 <input type="hidden" name="boardKind"  value="${requestScope.boardNo}">
 <input type="hidden" name="page"  value="${requestScope.page}">
	<table align="center">
	<tr><td>제목:<input type="text" name="title"></td></tr>
		<c:if test="${requestScope.boardNo==21}">
		<tr><td colspan="2">
				<input type="file" name="uploadFile" >
		</td></tr>
	</c:if>
	<c:if test="${requestScope.boardNo!=21}">
		<tr><td colspan="2"><textarea name="content" rows="15" cols="40"></textarea> </td></tr>
	</c:if>
	</table>
	<br>
	<center>
	<input type="button" value="글쓰기" class="writeBoardBtn" onclick="writeBoard('${requestScope.boardNo}')">
	</center>
	</form>
</body>
</html>